<script type="text/javascript">
	
function TreeNode(x) {
    this.val = x;
    this.left = null;
    this.right = null;
}
// {8,6,6,5,7,7,5}
let a = new TreeNode(8);
let b = new TreeNode(6);
let c = new TreeNode(6);
let d = new TreeNode(5);
let e = new TreeNode(7);
let f = new TreeNode(7);
let g = new TreeNode(5);
a.left = b;
a.right = c;
b.left = d;
b.right = e;
c.left = f;
c.right = g;

function isSymmetrical(pRoot)
{
    function fun(leftRoot, rightRoot) {
    	// debugger
        // 比较左右子树是否相同,如果不同放回false
        if(leftRoot.val != rightRoot.val) return false;
        let res1 = true, res2 = true;
        if(leftRoot.left && rightRoot.right) {
            res1 = fun(leftRoot.left, rightRoot.right);
        }
        // 否则比较左的左子树和右的右子树是否相同
        if(leftRoot.rihgt && rightRoot.left) {
            res2 = fun(leftRoot.right, rightRoot.left);
        }
        // 比较左子树的右结点和右子树的左节点
        return res1 && res2;
    }
    if(!pRoot) return false;
    return fun(pRoot.left, pRoot.right);
}

const res = isSymmetrical(a);
console.log(res)

</script>